package org.jdesktop.swingx.input;

import java.awt.Color;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.geom.Point2D;

import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

import org.jdesktop.swingx.JXMapViewer;
import org.jdesktop.swingx.PopUpMenu;
import org.jdesktop.swingx.mapviewer.GeoPosition;
import org.jdesktop.swingx.mapviewer.WaypointPainter;

import vnreal.ZNEW.GraphTest.Node;
import vnreal.ZNEW.GraphTest.SubstrateLink;
import vnreal.ZNEW.GraphTest.WorkOnPaths;
import vnreal.gui.menu.MapMenu;
import vnreal.map.FancyWaypointRenderer;
import vnreal.map.Map;
import vnreal.map.MyWaypoint;

/**
 * Centers the map on the mouse cursor if Right is double-clicked or middle
 * mouse button is pressed.
 * 
 * @author Martin Steiger
 * @author joshy
 */
public class ContextMenu extends MouseAdapter {
	private JXMapViewer viewer;

	public ContextMenu(JXMapViewer viewer) {
		this.viewer = viewer;
	}

	public void mousePressed(MouseEvent ev) {
		if (ev.isPopupTrigger()) {
			PopUpMenu menu = new PopUpMenu(viewer, ev);
			menu.show(ev.getComponent(), ev.getX(), ev.getY());
		}
	}

	public void mouseReleased(MouseEvent ev) {
		if (ev.isPopupTrigger()) {
			PopUpMenu menu = new PopUpMenu(viewer, ev);
			menu.show(ev.getComponent(), ev.getX(), ev.getY());
		}
	}

	public void mouseClicked(MouseEvent ev) {
	}
}
